package org.yuanqiframework.yuanqi.core.utils;

/**
 * @author 曹波涛
 */
public class PhoneEncodeUtils {
    /**
     * 手机号长度
     */
    private static final Integer LEN = 11;

    /**
     * 手机号脱敏
     *
     * @param phone
     * @return
     */
    public static String encodeMiddle(String phone) {
        if (phone == null || phone.length() != LEN)
            return phone;
        return phone.substring(0, 3) + "****" + phone.substring(7, 11);
    }

    /**
     * 手机后四位
     *
     * @param phone
     * @return
     */
    public static String getLastFour(String phone) {
        if (phone == null || phone.length() != LEN)
            return phone;
        return phone.substring(7, 11);
    }


}
